package com.aspose.cells;

public final class CellArea implements com.aspose.cells.b.a.zi {
   static CellArea a = createCellArea(1, 1, 0, 0);
   public int StartRow;
   public int EndRow;
   public int StartColumn;
   public int EndColumn;

   public int compareTo(Object obj) {
      CellArea var2 = (CellArea)obj;
      if (this.StartRow > var2.StartRow) {
         return 1;
      } else if (this.StartRow < var2.StartRow) {
         return -1;
      } else if (this.StartColumn > var2.StartColumn) {
         return 1;
      } else {
         return this.StartColumn < var2.StartColumn ? -1 : 0;
      }
   }

   public String toString() {
      StringBuilder var1 = new StringBuilder();
      var1.append("Aspose.Cells.CellArea(");
      var1.append(CellsHelper.cellIndexToName(this.StartRow, this.StartColumn));
      var1.append(":");
      var1.append(CellsHelper.cellIndexToName(this.EndRow, this.EndColumn));
      var1.append(")");
      var1.append("[");
      var1.append(this.StartRow);
      var1.append(",");
      var1.append(this.StartColumn);
      var1.append(",");
      var1.append(this.EndRow);
      var1.append(",");
      var1.append(this.EndColumn);
      var1.append("]");
      return com.aspose.cells.b.a.zr.a(var1);
   }

   boolean a(CellArea var1) {
      return this.EndRow >= var1.StartRow && this.StartRow <= var1.EndRow && this.EndColumn >= var1.StartColumn && this.StartColumn <= var1.EndColumn;
   }

   int b(CellArea var1) {
      if (this.EndRow >= var1.StartRow && this.StartRow <= var1.EndRow && this.EndColumn >= var1.StartColumn && this.StartColumn <= var1.EndColumn) {
         if (this.StartRow < var1.StartRow) {
            return this.EndRow >= var1.EndRow && this.StartColumn <= var1.StartColumn && this.EndColumn >= var1.EndColumn ? 4 : 2;
         } else if (this.StartRow == var1.StartRow) {
            if (this.EndRow < var1.EndRow) {
               return this.StartColumn >= var1.StartColumn && this.EndColumn <= var1.EndColumn ? 3 : 2;
            } else if (this.EndRow == var1.EndRow) {
               if (this.StartColumn < var1.StartColumn) {
                  return this.EndColumn >= var1.EndColumn ? 4 : 2;
               } else if (this.StartColumn == var1.StartColumn) {
                  if (this.EndColumn < var1.EndColumn) {
                     return 3;
                  } else {
                     return this.EndColumn == var1.EndColumn ? 1 : 4;
                  }
               } else {
                  return this.EndColumn <= var1.EndColumn ? 3 : 2;
               }
            } else {
               return this.StartColumn <= var1.StartColumn && this.EndColumn >= var1.EndColumn ? 4 : 2;
            }
         } else {
            return this.EndRow <= var1.EndRow && this.StartColumn >= var1.StartColumn && this.EndColumn <= var1.EndColumn ? 3 : 2;
         }
      } else {
         return 0;
      }
   }

   boolean a() {
      return this.EndRow < this.StartRow;
   }

   boolean b() {
      return this.StartRow == this.EndRow && this.StartColumn == this.EndColumn;
   }

   boolean c() {
      return this.StartRow == this.EndRow;
   }

   boolean d() {
      return this.StartColumn == this.EndColumn;
   }

   boolean a(int var1, int var2) {
      return var1 >= this.StartRow && var1 <= this.EndRow && var2 >= this.StartColumn && var2 <= this.EndColumn;
   }

   int e() {
      return this.EndRow - this.StartRow + 1;
   }

   int f() {
      return this.EndColumn - this.StartColumn + 1;
   }

   String a(int var1, int var2, boolean var3) {
      if (!var3) {
         if (this.StartRow == this.EndRow && this.StartColumn == this.EndColumn) {
            return CellsHelper.cellIndexToName(this.StartRow, this.StartColumn);
         } else if (this.StartRow == 0 && this.EndRow >= var1) {
            return CellsHelper.columnIndexToName(this.StartColumn) + ":" + CellsHelper.columnIndexToName(this.EndColumn);
         } else {
            return this.StartColumn == 0 && this.EndColumn >= var2 ? this.StartRow + 1 + ":" + (this.EndRow + 1) : CellsHelper.cellIndexToName(this.StartRow, this.StartColumn) + ":" + CellsHelper.cellIndexToName(this.EndRow, this.EndColumn);
         }
      } else {
         StringBuilder var4 = new StringBuilder();
         if (this.StartRow == this.EndRow && this.StartColumn == this.EndColumn) {
            var4.append("$");
            var4.append(CellsHelper.columnIndexToName(this.StartColumn));
            var4.append("$");
            var4.append(this.StartRow + 1);
         } else if (this.StartRow == 0 && this.EndRow >= var1) {
            var4.append("$");
            var4.append(CellsHelper.columnIndexToName(this.StartColumn));
            var4.append(":$");
            var4.append(CellsHelper.columnIndexToName(this.EndColumn));
         } else if (this.StartColumn == 0 && this.EndColumn >= var2) {
            var4.append("$");
            var4.append(this.StartRow + 1);
            var4.append(":$");
            var4.append(this.EndRow + 1);
         } else {
            var4.append("$");
            var4.append(CellsHelper.columnIndexToName(this.StartColumn));
            var4.append("$");
            var4.append(this.StartRow + 1);
            var4.append(":");
            var4.append("$");
            var4.append(CellsHelper.columnIndexToName(this.EndColumn));
            var4.append("$");
            var4.append(this.EndRow + 1);
         }

         return com.aspose.cells.b.a.zr.a(var4);
      }
   }

   boolean a(int var1) {
      return this.StartColumn == 0 && this.EndColumn >= var1;
   }

   boolean b(int var1) {
      return this.StartRow == 0 && this.EndRow >= var1;
   }

   static CellArea c(CellArea var0) {
      CellArea var1 = new CellArea();
      var1.StartRow = var0.StartRow;
      var1.StartColumn = var0.StartColumn;
      var1.EndRow = var0.EndRow;
      var1.EndColumn = var0.EndColumn;
      return var1;
   }

   public static CellArea createCellArea(int startRow, int startColumn, int endRow, int endColumn) {
      CellArea var4 = new CellArea();
      var4.StartRow = startRow;
      var4.StartColumn = startColumn;
      var4.EndRow = endRow;
      var4.EndColumn = endColumn;
      return var4;
   }

   static CellArea a(String var0) {
      String[] var1 = com.aspose.cells.b.a.zv.d(var0, ':');
      return var1.length > 1 ? createCellArea(var1[0], var1[1]) : createCellArea(var1[0], (String)null);
   }

   public static CellArea createCellArea(String startCellName, String endCellName) {
      startCellName = com.aspose.cells.b.a.zv.a(startCellName, "$", "");
      CellArea var2 = new CellArea();
      byte var3 = 0;
      byte var4 = 0;
      int[] var5 = new int[]{var3};
      int[] var6 = new int[]{var4};
      CellsHelper.a(startCellName, var5, var6);
      int var7 = var5[0];
      int var8 = var6[0];
      var2.StartRow = var7;
      var2.StartColumn = var8;
      if (endCellName != null) {
         endCellName = com.aspose.cells.b.a.zv.a(endCellName, "$", "");
         var5 = new int[]{var7};
         var6 = new int[]{var8};
         CellsHelper.a(endCellName, var5, var6);
         var7 = var5[0];
         var8 = var6[0];
         var2.EndRow = var7;
         var2.EndColumn = var8;
      }

      return var2;
   }

   static Object a(String var0, boolean var1) {
      if (var0 != null && !"".equals(var0)) {
         char[] var2 = var0.toCharArray();
         CellArea var3 = new CellArea();
         CellArea var4 = null;
         if (var1) {
            var4 = var3;
         }

         int var5 = var0.indexOf(58);
         int[] var6;
         if (var5 == -1) {
            var6 = CellsHelper.a(var2, 0, var2.length - 1, false, 1048575, 16383);
            if (var6 == null) {
               return var4;
            }

            var3.StartColumn = var3.EndColumn = var6[1];
            var3.StartRow = var3.EndRow = var6[0];
         } else {
            var6 = CellsHelper.a(var2, 0, var5 - 1, true, 1048575, 16383);
            if (var6 == null) {
               return var4;
            }

            var3.StartColumn = var6[1];
            var3.StartRow = var6[0];
            var6 = CellsHelper.a(var2, var5 + 1, var2.length - 1, true, 1048575, 16383);
            if (var6 == null) {
               return var4;
            }

            var3.EndColumn = var6[1];
            var3.EndRow = var6[0];
            if (var3.StartColumn == -1) {
               if (var3.EndColumn != -1) {
                  return var4;
               }

               var3.StartColumn = 0;
               var3.EndColumn = 16383;
            } else if (var3.EndColumn == -1) {
               return var4;
            }

            if (var3.StartRow == -1) {
               if (var3.EndRow != -1) {
                  return var4;
               }

               var3.StartRow = 0;
               var3.EndRow = 1048575;
            } else if (var3.EndRow == -1) {
               return var4;
            }

            int var7;
            if (var3.StartColumn > var3.EndColumn) {
               var7 = var3.StartColumn;
               var3.StartColumn = var3.EndColumn;
               var3.EndColumn = var7;
            }

            if (var3.StartRow > var3.EndRow) {
               var7 = var3.StartRow;
               var3.StartRow = var3.EndRow;
               var3.EndRow = var7;
            }
         }

         return var3;
      } else {
         return null;
      }
   }

   void d(CellArea var1) {
      this.StartRow = var1.StartRow;
      this.EndRow = var1.EndRow;
      this.StartColumn = var1.StartColumn;
      this.EndColumn = var1.EndColumn;
   }

   boolean e(CellArea var1) {
      if (this.StartRow != var1.StartRow) {
         return false;
      } else if (this.EndRow != var1.EndRow) {
         return false;
      } else if (this.StartColumn != var1.StartColumn) {
         return false;
      } else {
         return this.EndColumn == var1.EndColumn;
      }
   }
}
